package com.fpost.form;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import com.fpost.form.dto.ArticleDTO;
import com.fpost.form.dto.ArticleTypeDTO;
import com.fpost.util.FpostCache;

public class AdvancedSearchForm extends ActionForm {
	
	private String authorId;
	private String author;
	private String input;
	private String resultCount;	
	private String searchTime;
	private String message1;
	private String message2;
	
	private List<ArticleDTO> articleDTOList = new ArrayList<ArticleDTO>();
	
	private String articleTypeId; // this is what select returns	
	private List<ArticleTypeDTO> articleTypeDTOList;
	
	public ActionErrors validate(ActionMapping mapping,	HttpServletRequest request) {

		ActionErrors errors = new ActionErrors();		
		
		if ("".equals(input)) {
			errors.add("input", new ActionMessage("error.input.empty"));
		}
		return errors;
	}	
	
	public String getAuthorId() {
		return authorId;
	}

	public void setAuthorId(String authorId) {
		this.authorId = authorId;
	}

	public String getAuthor() {
		return author;
	}

	public void setAuthor(String author) {
		this.author = author;
	}

	public String getInput() {
		return input;
	}

	public void setInput(String input) {
		this.input = input;
	}

	public String getResultCount() {
		return resultCount;
	}

	public void setResultCount(String resultCount) {
		this.resultCount = resultCount;
	}

	public List<ArticleTypeDTO> getArticleTypeDTOList() {
		return FpostCache.getInstance().getArticleTypeDTOList();
	}

	public void setArticleTypeDTOList(List<ArticleTypeDTO> articleTypeDTOList) {
		this.articleTypeDTOList = articleTypeDTOList;
	}

	public List<ArticleDTO> getArticleDTOList() {
		return articleDTOList;
	}

	public void setArticleDTOList(List<ArticleDTO> articleDTOList) {
		this.articleDTOList = articleDTOList;
	}

	public String getArticleTypeId() {
		return articleTypeId;
	}

	public void setArticleTypeId(String articleTypeId) {
		this.articleTypeId = articleTypeId;
	}

	public String getSearchTime() {
		return searchTime;
	}

	public void setSearchTime(String searchTime) {
		this.searchTime = searchTime;
	}

	public String getMessage1() {
		return message1;
	}

	public void setMessage1(String message1) {
		this.message1 = message1;
	}

	public String getMessage2() {
		return message2;
	}

	public void setMessage2(String message2) {
		this.message2 = message2;
	}
	
}
